<?php
/*
Template Name: Page - test template
*/

get_header(); 

?>
</div>
<div class="upper_edge"></div>
<div class="small_edge">
    <div style="width:960px; margin: 0 auto;">
        Hình ảnh
    </div>
</div>
<div class="lower_edge"></div>
<div style="width:960px; margin: 0 auto;" class="clear">
<?php 
$post_widget_count = 1;
global $wp_query;
$args=array('placecategory' => 'cat-toc-lam-toc',
				  'post_type' => 'attachment',//CUSTOM_POST_TYPE1,
				  'posts_per_page' => 7,
				  'caller_get_posts'=> 1,
                  'paged'   => isset($_GET['paged']) ? $_GET['paged'] : 1
                );
                $temp = $wp_query;
                $wp_query = null;
				$wp_query = new WP_Query($args);
				if( $wp_query->have_posts() ) {?>
      <div id="loop" class="grid clear">	
				<?php if($title){?> 
					<h3><span><?php _e($title,'templatic');?></span>
					<?php if($link){?><a href="<?php _e($link,'templatic');?>" class="more" ><?php _e($text,'templatic');?></a><?php }?>
         
					</h3> <?php }?>
			<?php   while ($wp_query->have_posts()) : $wp_query->the_post();
            var_dump($post);die();
					$post_images =  bdw_get_images_with_info($post->ID,'large');   
					$attachment_id = $post_images[0]['id']; ?>	
					
					<?php foreach ($post_images as $image):?>
					<?php 
						$attachment_id = $image['id']; 
						$alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true);
						$attach_data = get_post($attachment_id);
						$title = $attach_data->post_title;
					?>
					<div id="post_<?php the_ID(); ?>" <?php if((get_post_meta($post->ID,'is_featured',true) == 1) && (get_post_meta($post->ID,'featured_type',true) =="both" || get_post_meta($post->ID,'featured_type',true) =="h")){ post_class('post featured_post');} else { post_class('post');}?>>
						<div class="post-content">
							<a class="post_img" href="<?php the_permalink(); ?>"><img  src="<?php echo $image['file'];?>" alt="<?php $alt; ?>" title="<?php echo $title; ?>"  /> </a>
							<div class="post_content">
								<h2><a class="widget-title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> 
							</div>     
						</div>                      
					</div>
					<?php endforeach;?>
					<?php /*
					<?php if((get_post_meta($post->ID,'is_featured',true) ==1) && ( get_post_meta($post->ID,'featured_type',true) =="both" || get_post_meta($post->ID,'featured_type',true) =="h")){?>
							<span class="featured_img"><?php _e('featured','templatic');?></span>
					<?php }
					$alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true);
					$attach_data = get_post($attachment_id);
					$title = $attach_data->post_title;
					$width = get_option('thumbnail_size_w');
					$height = get_option('thumbnail_size_h');
					$is_crop = get_option('thumbnail_crop');
					if($is_crop == 1){ $is_crop = 'true'; }else{ $is_crop = 'false'; }
					if($title ==''){ $title = $post->post_title; }
					if($alt ==''){ $alt = $post->post_title; }
					if($post_images[0]['file']){  
					$crop_image = vt_resize($attachment_id, $post_images[0]['file'], $width, $height, $crop = $is_crop );
					?>
						<a class="post_img" href="<?php the_permalink(); ?>"><img  src="<?php echo $crop_image['url'];?>" alt="<?php $alt; ?>" title="<?php echo $title; ?>"  /> </a>
					
					<?php
					}else {?>
						<a class="img_no_available" href="<?php the_permalink(); ?>"> <?php _e('Image Not Available','templatic')?> </a>
					<?php } ?>
						*/?>
					
          <?php  
		  
		  if($post_widget_count == '4') {
				echo '<div class="hr clearfix"></div>';
				$post_widget_count = 0;
            } 
            
	 $post_widget_count++;
	 endwhile;?>
        <div class="pagination">
        <!-- ADD Custom Numbered Pagination code. -->
        <?php if(function_exists('pagenavi')) { 
            pagenavi(); 
        }
         ?>
        </div>
	</div>
	<?php $wp_query = null;
$wp_query = $temp;wp_reset_query();}?>
<?php //get_sidebar(); ?>
<?php //get_footer();?>
